<template>
  <div class="toast"
       v-show="show">
    <div>{{message}}</div>
  </div>
</template>

<script>
export default {
  name: 'Toast',
  // props: {
  //   message: {
  //     type: String,
  //     default: '我是弹窗内容~'
  //   },
  //   show: {
  //     type: Boolean,
  //     default: false
  //   }
  // },
  data() {
    return {
      message: '',
      show: false
    };
  },
  created() {

  },
  mounted() {

  },
  methods: {
    shows(message = "我是默认内容~", duration = 2000) {
      this.show = true
      this.message = message

      setTimeout(() => {
        this.show = false;
        this.message = ''
      }, duration)
    }
  }
};
</script>

<style scoped>
.toast {
  max-width: 200px;
  position: fixed;
  top: 50%;
  left: 50%;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  color: #fff;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  word-wrap: break-word;
  text-align: center;
  z-index: 9999;
}
</style>
